import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '渠道号',
    align:"center",
    dataIndex: 'cpid'
   },
   {
    title: '渠道名称',
    align:"center",
    dataIndex: 'cpName'
   },
   {
    title: '业务号',
    align:"center",
    dataIndex: 'serviceId'
   },
   {
    title: '业务名称',
    align:"center",
    dataIndex: 'serviceName'
   },
   {
    title: '密钥',
    align:"center",
    dataIndex: 'token'
   },
   {
    title: '白名单ip',
    align:"center",
    dataIndex: 'ip'
   },
   {
    title: '启用',
    align:"center",
    dataIndex: 'switchCp',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}])
     },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "渠道号",
      field: 'cpid',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "业务号",
      field: 'serviceId',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '渠道号',
    field: 'cpid',
    component: 'Input',
  },
  {
    label: '渠道名称',
    field: 'cpName',
    component: 'Input',
  },
  {
    label: '业务号',
    field: 'serviceId',
    component: 'Input',
  },
  {
    label: '业务名称',
    field: 'serviceName',
    component: 'Input',
  },
  {
    label: '密钥',
    field: 'token',
    component: 'Input',
    dynamicDisabled:true
  },
  {
    label: '白名单ip',
    field: 'ip',
    component: 'Input',
  },
  {
    label: '启用',
    field: 'switchCp',
     component: 'JSwitch',
     componentProps:{
         options:[1,0]
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表列表数据
export const testCpInterfaceColumns: BasicColumn[] = [
   {
    title: '接口编码',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '接口名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '请求类型',
    align:"center",
    dataIndex: 'type'
   },
   {
    title: '启用',
    align:"center",
    dataIndex: 'switchCp',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}])
     },
   },
];
//子表列表数据
export const testCpErrorColumns: BasicColumn[] = [
   {
    title: '接口编码',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '接口名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '报警信息',
    align:"center",
    dataIndex: 'msg'
   },
   {
    title: '通知结果',
    align:"center",
    dataIndex: 'type'
   },
];
//子表表格配置
export const testCpInterfaceJVxeColumns: JVxeColumn[] = [
    {
      title: '接口编码',
      key: 'code',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '接口名称',
      key: 'name',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '请求类型',
      key: 'type',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '启用',
      key: 'switchCp',
      type: JVxeTypes.checkbox,
      customValue: [1,0],
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]
export const testCpErrorJVxeColumns: JVxeColumn[] = [
    {
      title: '接口编码',
      key: 'code',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '接口名称',
      key: 'name',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '报警信息',
      key: 'msg',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '通知结果',
      key: 'type',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  cpid: {title: '渠道号',order: 0,view: 'text', type: 'string',},
  cpName: {title: '渠道名称',order: 1,view: 'text', type: 'string',},
  serviceId: {title: '业务号',order: 2,view: 'text', type: 'string',},
  serviceName: {title: '业务名称',order: 3,view: 'text', type: 'string',},
  token: {title: '密钥',order: 4,view: 'text', type: 'string',},
  ip: {title: '白名单ip',order: 5,view: 'text', type: 'string',},
  switchCp: {title: '启用',order: 6,view: 'number', type: 'number',},
  //子表高级查询
  testCpInterface: {
    title: '接口授权',
    view: 'table',
    fields: {
        code: {title: '接口编码',order: 0,view: 'text', type: 'string',},
        name: {title: '接口名称',order: 1,view: 'text', type: 'string',},
        type: {title: '请求类型',order: 2,view: 'text', type: 'string',},
        switchCp: {title: '启用',order: 3,view: 'switchCp', type: 'string',},
    }
  },
  testCpError: {
    title: '报警信息',
    view: 'table',
    fields: {
        code: {title: '接口编码',order: 0,view: 'text', type: 'string',},
        name: {title: '接口名称',order: 1,view: 'text', type: 'string',},
        msg: {title: '报警信息',order: 2,view: 'text', type: 'string',},
        type: {title: '通知结果',order: 3,view: 'text', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
